import { NextResponse } from "next/server";
import contactModule from "@/modules/contact";

export async function POST(request) {
  const codeMap = {0: '信息更新成功', 1: '信息更新失败'};
  const data = await request.json();
  const result = await contactModule.update(data);
  if (result.affectedRows !== 1) {
    return NextResponse.json({ code: 1, message: "Contact update failed", data: null, codeMap }, { status: 500 });
  }
  return NextResponse.json({ code: 0, message: "Contact updated successfully", data: result, codeMap });
}